import 'package:pacsun/theme/app_colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

// 点赞方向枚举
/// 点赞方向
/// [horizontal] 水平排列
/// [vertical] 垂直排列
enum Direction { horizontal, vertical }

/// 点赞容器组件
/// 用于显示点赞数和点赞状态的容器
class LikeContainer extends StatelessWidget {
  /// 是否已点赞
  final bool isLiked;

  /// 点赞数
  final String likes;

  /// 显示方向（水平/垂直）
  final Direction direction;

  /// 背景色
  final Color background;

  // 主轴排列
  final MainAxisAlignment mainAxisAlignment;
  const LikeContainer({
    super.key,
    required this.isLiked,
    required this.likes,
    this.direction = Direction.horizontal,
    this.mainAxisAlignment = MainAxisAlignment.center,
    this.background = const Color.fromRGBO(4, 4, 4, 0.4),
  });

  @override
  Widget build(BuildContext context) {
    final Axis flexDirection =
        direction == Direction.horizontal ? Axis.horizontal : Axis.vertical;
    return Container(
      decoration: BoxDecoration(
        color: background,
        borderRadius: BorderRadius.circular(9.5).r,
      ),
      padding: EdgeInsets.symmetric(horizontal: 6, vertical: 3).r,
      child: Flex(
        direction: flexDirection,
        mainAxisAlignment: mainAxisAlignment,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Icon(
            isLiked ? Icons.favorite : Icons.favorite_border,
            size: 13.sp,
            color: isLiked ? Colors.red : Colors.white,
          ),
          SizedBox(width: 4.w),
          Text(
            likes.toString(),
            style: customTextStyle(
              fontWeight: 700,
              fontFamily: FontFamily.gilroyBold,
            ),
          ),
        ],
      ),
    );
  }
}
